#include <stdio.h>
#include <math.h>
#include <conio.h>

struct Point
{
	float x;
	float y;	
};

void BruteForceClosestPoint(Point p[], int n)
{
	float distance = 1000000000;
	int p1, p2;
	for(int i = 1; i <= n-1; i++)
	{
		for(int j = i+1; j <= n; j++)
		{
			float d = sqrt( (p[i].x - p[j].x)*(p[i].x - p[j].x) + (p[i].y - p[j].y)*(p[i].y - p[j].y) );
			if (d < distance)
			{
				distance = d;
				p1 = i;
				p2 = j;
				
			}
		}
	}
	printf("Diem 1: (%0.2f,%0.2f) | Diem 2: (%0.2f, %0.2f)\n", p[p1].x, p[p1].y, p[p2].x, p[p2].y);
	printf("Khoang cach: %f", distance);
	//return distance;	
}

void main()
{
	Point p1;
	Point p2, p3;	
	Point p[10];	
	p[1].x = 3;
	p[1].y = 1;
	p[2].x = -1;
	p[2].y = 5;
	p[3].x = -3;
	p[3].y = -3;
	p[4].x = 1;
	p[4].y = 2;
	BruteForceClosestPoint(p,4);
}
